package it.koutifaris.travianmap.view.serversview;

import it.koutifaris.travianmap.R;
import it.koutifaris.travianmap.view.serversview.ServersView.ServersViewItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

public class ServersViewItemImpl implements ServersViewItem {

	private final View androidView;

	public ServersViewItemImpl(View androidView) {
		this.androidView = androidView;
		getDeleteIcon().setVisibility(View.INVISIBLE);
	}

	@Override
	public View getView() {
		return androidView;
	}

	@Override
	public void setDeleteClickHandler(OnClickListener clickListener) {
		getDeleteIcon().setOnClickListener(clickListener);
		getDeleteIcon().setVisibility(View.VISIBLE);
	}

	@Override
	public void setLabel(String label) {
		getServerLabel().setText(label);
	}

	private TextView getServerLabel() {
		return (TextView) androidView.findViewById(R.id.serversListItemLabel);
	}

	private ImageView getDeleteIcon() {
		return (ImageView) androidView.findViewById(R.id.serversListItemDeleteIcon);
	}

}
